package com.daohang361.imqq.pugin.decoder;

import com.daohang361.imqq.Asycore.QQUser;
import com.daohang361.imqq.decoder.InterfaceDecoder;
import com.daohang361.imqq.tool.Hex2Bytes;
import com.daohang361.imqq.tool.MyByteReciveArray;

/** 
 * @author naner E-mail:likun3344@163.com 
 * @create time：2011-6-5 上午12:05:43 
 * 获取图片相关信息
 */
public class DecoderD1 implements InterfaceDecoder{
	public MyByteReciveArray myArray;
	public QQUser sessionQQ;
	public byte[] decryptAll=null;
	@Override
	public void init(MyByteReciveArray myArray, QQUser sessionQQ) {
		this.myArray=myArray;
		this.sessionQQ=sessionQQ;
	}
	@Override
	public QQUser decode() throws Exception {
		myArray.decryptRemain(sessionQQ.getAttr("SessionKey"));
		myArray.extract(0, 2);//00 0c 03
		myArray.extract(0, 26);
		myArray.extract(0, 1);//00 38
		myArray.extract(0, 55);
		myArray.extract(0, 4);//00 81 00 00 04
		byte[] imgKey=myArray.extract(0, 15);//imgKey
		sessionQQ.addAttr("imgKey", imgKey);
		System.out.println("imgKey:"+Hex2Bytes.bytesToHexString(imgKey));
		myArray.extract(0, 12);
		byte[] token_data_d1 = myArray.extract(0, 0x38-1);
		sessionQQ.addAttr("token_data_d1", token_data_d1);
		sessionQQ.setCommand(0);//不回复,即HexEncodeProtocol失效
		
		return sessionQQ;
	}
	
	/**
	 * 暴力打印
	 */
	public void violence()
	{
		//new ViolenceBytes(decryptAll).violence();
	}

	@Override
	public Object invoke(Object... o) {
		// TODO Auto-generated method stub
		return null;
	}

}
